package xyz.imeans.w.config;

import xyz.imeans.w.service.CreateService;
import xyz.imeans.w.service.core.TestService;

import java.util.Date;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class InitCreateFactory {

    private static Map<FieldEnum, TestService> serviceMap = new ConcurrentHashMap<>(10);
    private static Map<CreateEnum, CreateService> createServiceMap = new ConcurrentHashMap<>(10);

    // 时间标记，用于每类数据生成时间处理
    public static Date DATE_FLAG = new Date();

    public static TestService getService(FieldEnum type){
        return serviceMap.get(type);
    }

    public static void initService(FieldEnum type, TestService service) {
        serviceMap.put(type, service);
    }

    public static void clear(){
        serviceMap.clear();
    }

    public static CreateService getCreateService(CreateEnum type){
        DATE_FLAG = new Date();
        return createServiceMap.get(type);
    }

    public static void initCreateService(CreateEnum type, CreateService service) {
        createServiceMap.put(type, service);
    }

    public static void clearCreate(){
        createServiceMap.clear();
    }
}
